package com.gitee.wsl.data.value

//fun <T : Any> Value<T>.subscribe(
//    lifecycle: Lifecycle,
//    mode: ObserveLifecycleMode = ObserveLifecycleMode.START_STOP,
//    observer: (T) -> Unit,
//) {
//    var cancellation: Cancellable? = null
//
//    when (mode) {
//        ObserveLifecycleMode.CREATE_DESTROY ->
//            lifecycle.subscribe(
//                onCreate = { cancellation = subscribe(observer) },
//                onDestroy = { cancellation?.cancel() },
//            )
//
//        ObserveLifecycleMode.START_STOP ->
//            lifecycle.subscribe(
//                onStart = { cancellation = subscribe(observer) },
//                onStop = { cancellation?.cancel() },
//            )
//
//        ObserveLifecycleMode.RESUME_PAUSE ->
//            lifecycle.subscribe(
//                onResume = { cancellation = subscribe(observer) },
//                onPause = { cancellation?.cancel() },
//            )
//    }.let {}
//}

enum class ObserveLifecycleMode {
    CREATE_DESTROY,
    START_STOP,
    RESUME_PAUSE
}
